package edu.sctu.fengleilin.month06.day150628;

/**
 * Created by user09 on 2015/6/28.
 */
public class ThreadTicket implements Runnable{

    private int ticket = 5;
    @Override
    public void run() {
        for (int i = 0; i < 10;i ++) {
            synchronized (this) {
                if (ticket > 0) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("车票" + ticket--);
                }
            }
        }
    }
}
